#include "../include/head.h"

int pthread_func(taskNode_t *get_node,RequestPackage* sharedRequest)
{
    int netfd = get_node->netfd;
    MSG_TYPE type = get_node->type;
    // printf("tasktype:%d\n", type);
    // char virtualpath_buf[1024];
    // memcpy(virtualpath_buf, get_node->virtualPath, strlen(get_node->virtualPath));
    // int virtualpath_len = strlen(virtualpath_buf);

    // char args_buf[1024];
    // memcpy(args_buf, get_node->args, strlen(get_node->args));
    // int args_len = strlen(args_buf);

    // sharedRequest->type = type;
    // sharedRequest->vir_path_len = virtualpath_len;
    // memcpy(sharedRequest->vir_path_val, virtualpath_buf, virtualpath_len);
    // sharedRequest->args_len = args_len;
    // memcpy(sharedRequest->args_val, args_buf, args_len);

    // printf("type = %d\n", sharedRequest->type);
    // printf("v_len = %d\n", sharedRequest->vir_path_len);
    // printf("v_path = %s\n", sharedRequest->vir_path_val);
    // printf("args_len = %d\n", sharedRequest->args_len);
    // printf("args = %s\n", sharedRequest->args_val);

    if (type == C_OP_CD)
    {
        server_cd(sharedRequest,serverDir,netfd);
    }
    else if(type == C_OP_LS)
    {
        server_ls(sharedRequest,serverDir, netfd);
    }
    else if(type == C_OP_PWD)
    {
        server_pwd(sharedRequest,serverDir, netfd);
    }
    else if(type == C_OP_MKDIR)
    {
        server_mkdir(sharedRequest,serverDir,netfd);
    }
    else if(type == C_OP_RMDIR)
    {
        server_rmdir(sharedRequest,serverDir,netfd);
    }
    else if(type == C_OP_REMOVE)
    {
        server_rmfile(sharedRequest, serverDir,netfd);
    }
     else if(type == C_OP_PUTS_BEGIN)
     {
         //server_puts(sharedRequest, netfd, get_node->epfd);
         server_puts_mmap2(sharedRequest, netfd, get_node->epfd);
     }
     else if(type == C_OP_GETS_BEGIN)
     {
         //server_gets(sharedRequest, netfd, get_node->epfd);
         server_gets_mmap(sharedRequest, netfd, get_node->epfd);
     }
    return 1;
}
